home *** CD-ROM | disk | FTP | other *** search
- 'This code is applicable for MsWord V.6.0
-
- 'Place the following code in a WordBasic Macro
- 'called Backup. Consult with Word's Help for how to create and run
- 'a Macro.
-
- Dim Shared Channel, SourceApp$, SourceForm$, SourceControl$
- Sub MAIN
- On Error Resume Next
- If AppIsRunning("Hidden DDE Server") = 0 Then
- 'Note: "Hidden DDE Server" is the Caption value of ZipForm
- Shell "C:\ZIPSERV\ZIPSERV.EXE -1"
- End If
- SourceApp$ = "ZIPSERV"
- SourceForm$ = "ZipForm"
- SourceControl$ = "DDELabel"
- Counter = 0
- While AppIsRunning("Hidden DDE Server") = 0
- Counter = Counter + 1
- If Counter = 100 Then Goto AfterWend
- Wend
- AfterWend:
- If Not AppIsRunning("Hidden DDE Server") = 0 Then
- Channel = DDEInitiate(SourceApp$, SourceForm$)
- Else
- MsgBox "Execution failed. Please repeat Backup"
- EndIf
- If Channel <> 0 Then
- 'application running
- 'in the example we are sending a message to zip all .DOC files
- 'into an WORDDOC.ZIP file in the same directory
- 'we are using as directory C:\MSOFFICE\WINWORD
- WordDir$ = "C:\MSOFFICE\WINWORD\"
- ZipFile$ = WordDir$ + "WORDDOC.ZIP"
- FilesToZip$ = WordDir$ + "*.DOC"
- KeepDate$ = "0" 'Change to "1" when updating and keep date
- StorePath$ = "0" 'Change to "1" when Yes
- Recursive$ = "0" 'Change to "1" when Yes
- Comment$ = "" 'No comment
- Password$ = "" 'No password
- Task$ = "0" 'Zipping, change it to "1" for unzipping
- s$ = ""
- s$ = s$ + Left$(ZipFile$ + String$(100, " "), 100)
- s$ = s$ + Task$
- If Task$ = "0" Then
- s$ = s$ + Left$(FilesToZip$ + String$(100, " "), 100)
- s$ = s$ + KeepDate$
- s$ = s$ + StorePath$
- s$ = s$ + Recursive$
- Else
- s$ = s$ + Left$(Destination$ + String$(100, " "), 100)
- s$ = s$ + Overwrite$ ' "0" - No , "1" - Yes
- s$ = s$ + RestorePath$ ' "0" - No , "1" - Yes
- EndIf
- s$ = s$ + Left$(Comment$ + String$(50, " "), 50)
- s$ = s$ + Left$(Password$ + String$(10, " "), 10)
- SendDDE s$
- SendDDE "" 'Unloads Zip Server
- EndIf
- ExitMain:
- End Sub
-
- Sub SendDDE(DDEInstruction$)
- 'Send and receive DDE commands/results to/from the
- 'hidden Zip server, using the local DDELabel control
- DDEPoke Channel, SourceControl$, DDEInstruction$
- If UCase$(DDEInstruction$) <> "" Then
- Response$ = DDERequest$(Channel, SourceControl$)
- While Response$ = DDEInstruction$ 'wait for execution
- Response$ = DDERequest$(Channel, SourceControl$)
- Wend
- 'MsgBox "Zip Server's Response: " + Response$
- 'you do not need this MsgBox, but might want to use
- 'Response$ value
- 'in the application. Note that it returns "-1" if the execution 'was successfull
- EndIf
- End Sub
-